﻿@using EasyAbp.AbpHelper.Gui.Solutions
@using EasyAbp.AbpHelper.Gui.Solutions.Dtos
@using Microsoft.Extensions.Localization
@using Volo.Abp.AspNetCore.Components.Web
@using EasyAbp.AbpHelper.Gui.Localization
@inherits EasyAbp.AbpHelper.Gui.Blazor.Pages.Solutions.Shared.SolutionManagementBase
<BarDropdown>
    <BarDropdownToggle>
        @(CurrentSolution.Value?.DisplayName ?? L["NoSolution"])
    </BarDropdownToggle>
    <BarDropdownMenu RightAligned="true">
        @foreach (var solution in Solutions)
        {
            <BarDropdownItem Clicked="() => ChangeSolutionAsync(solution)">
                @solution.DisplayName @if (CurrentSolution.Value.Equals(solution))
                                      {
                                          @($" ({L["Current"].Value})")
                                      }
            </BarDropdownItem>
        }
        <BarDropdownItem Clicked="OpenOpenSolutionModalAsync">
            <Icon Name="IconName.FolderOpen"/> @L["OpenSolution"]
        </BarDropdownItem>
        <BarDropdownItem Clicked="RedirectToSolutionsPageAsync">
            <Icon Name="IconName.List"/> @L["ManageSolutions"]
        </BarDropdownItem>
    </BarDropdownMenu>
</BarDropdown>

<Modal @ref="Modal">
    <ModalContent Size="ModalSize.Default" IsCentered="true">
        <ModalHeader>
            <ModalTitle>@L["OpenSolution"]</ModalTitle>
            <CloseButton Clicked="CloseOpenSolutionModal" />
        </ModalHeader>
        <ModalBody MaxHeight="50">
            <Validations Mode="ValidationMode.Auto" ValidateOnLoad="false">
                <Validation MessageLocalizer="@Lh.Localize">
                    <Field>
                        <FieldLabel>@L["SolutionDisplayName"]</FieldLabel>
                        <TextEdit @bind-Text="@CreateSolution.DisplayName">
                            <Feedback>
                                <ValidationError />
                            </Feedback>
                        </TextEdit>
                    </Field>
                </Validation>
                <Field>
                    <FieldLabel>@L["SolutionSolutionType"]</FieldLabel>
                    <Select TValue="SolutionType" @bind-SelectedValue="@CreateSolution.SolutionType">
                        @foreach (var solutionType in Enum.GetValues<SolutionType>())
                        {
                            <SelectItem Value="solutionType">
                                @L[$"SolutionType:{Enum.GetName(solutionType)}"]
                            </SelectItem>
                        }
                    </Select>
                </Field>
                <Validation MessageLocalizer="@Lh.Localize">
                    <Field>
                        <FieldLabel>@L["SolutionDirectoryPath"]</FieldLabel>
                        <TextEdit @bind-Text="@CreateSolution.DirectoryPath">
                            <Feedback>
                                <ValidationError />
                            </Feedback>
                        </TextEdit>
                    </Field>
                </Validation>
            </Validations>
        </ModalBody>
        <ModalFooter>
            <Button Color="Color.Secondary" Clicked="CloseOpenSolutionModal">@L["Cancel"]</Button>
            <Button Color="Color.Primary" Clicked="OpenSolutionExecuteAsync">@L["Open"]</Button>
        </ModalFooter>
    </ModalContent>
</Modal>